package function;

import model.Author;
import model.GetAuthors;

import java.util.List;
import java.util.stream.Stream;

public class FlatMap2 {
    public static void main(String[] args) {
        List<Author> authors = GetAuthors.getAuthors();
        authors.stream()
                .flatMap((author->author.getBooks().stream()))//转化为Book对象流
                .distinct()
                .flatMap(book -> Stream.of(book.getCategory().split(",")))//将book转换为种类
                .distinct()
                .filter(cate->!(cate.equals("哲学")||cate.equals("爱情")))
                .forEach(cate-> System.out.println(cate));


    }
}
